<%--
  Created by IntelliJ IDEA.
  User: dqf
  Date: 2015/4/20
  Time: 15:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://"
          + request.getServerName() + ":" + request.getServerPort()
          + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>密码重置</title>
  <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
  <script src="../resource/wechat/jweixinapi.js"></script>
  <jsp:include page="../../../main/mp/inc.jsp"	/>
  <script>
    $(function(){
      //$("[data-role='navbar']").navbar();
      //$("[data-role='header'], [data-role='footer']").toolbar();

      $("#btn-save-common").click(function(e){
        if($("select[name=oldPassword]").val()==""){
          alert("请输入原密码");
          return;
        }
        if($("select[name=newPassword]").val()==""){
          alert("请输入新密码");
          return;
        }
        if($("#newPassword").val()==$("#oldPassword").val()){
          alert("新密码和原密码不能相同");
          return;
        }
        if($("#newPassword").val()!=$("#confirmPassword").val()){
          alert("输入的新密码与确认密码不一致");
          return;
        }
        save_from();
      });

      function save_from(){
        if(!confirm("确定提交保存吗？")){
          return ;
        }
        $("#btn-save-common").hide();
        $.mobile.loading( "show", {
          text: "正在保存，请稍后...",
          textVisible: true,
          theme: "b",
          textonly: false,
          html: ""
        });
        $.ajax({
          type: "POST",
          url: $("form#form-common").attr("action"),
          cache:false,dataType:"json",
          data: $("form#form-common").serialize(),
          async:true,
          success: function(data){
            if(data.state == "200"){
              alert(data.message);
              location.replace("ajax!proInfo.action");
            }else{
              hide();
              $("#btn-save-common").show();
              alert(data.message);
            }
          }
        });
      }
    });

  </script>
</head>
<body>
<div data-role="page" >
  <div data-role="header" data-position="fixed" data-theme="a">
    <h1 style="float:left;margin: 0 10px;"><i class="fa fa-user"></i> 密码重置</h1>
    <a href="#" id="btn-save-common" class="ui-btn ui-btn-right ui-icon-check ui-corner-all ui-btn-icon-left">重置</a>
  </div><!-- /header -->
  <div class="ui-content jqm-content jqm-fullwidth" role="main">
    <form id="form-common" method="post" id="form-common" action="<%=basePath%>mp/ajax-users/reset" data-ajax="false">
      <div class="ui-field-contain">
        <label>原密码：</label>
        <span><input type="password" id="oldPassword" name="oldPassword" value=""></span>
      </div>
      <div class="ui-field-contain">
        <label>新密码：</label>
        <span><input type="password" id="newPassword" name="newPassword" value=""></span>
      </div>
      <div class="ui-field-contain">
        <label>确认新密码：</label>
        <span><input type="password" id="confirmPassword" name="confirmPassword" value=""></span>
      </div>
    </form>
  </div><!-- /content -->
</div>
</body>
</html>
